//标记为已读
/*function doread(msg_id) {

	$.ajax({
		type: 'get',
		url: httpAdress + '/api/message/doread',
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		data: {
			'msg_id':msg_id
		},
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {
			console.log('成功改变状态');
		},
		error: function() {
			console.log('出错了');

		}
	});
}*/
//获取内容
/*$.ajax({
	type: 'get',
	url: httpAdress + '/api/message/getmessage',
	contentType: "application/json; charset=utf-8",
	dataType: 'jsonp',
	data: {
				'userid': localStorage.getItem("userid")
	},
	jsonp: "callback",
	jsonpCallback: "successCallback",
	success: function(data) {
		console.log(data);
		var mydata = data.retData;
		console.log(data.message);
		for(var i = 0; i < mydata.length; i++) {
			$('<li class="mui-table-view-cell mui-media">'+
				'<a href="../../HTML/my/message_detail.html?text='+mydata[i].message+'">'+
					'<img class="mui-media-object mui-pull-left" src="../../image/other/img_wang@2x.png">'+
				'<div class="mui-media-body">'+
				'<p  class="mui-ellipsis firstline" >哎呀妈啊</p>'+
				'<p class="mui-ellipsis">发送于&nbsp;&nbsp;&nbsp;2018-03-13</p>'+
				'</div>'+
				'</a><div class="little_round"></div></li>').appendTo(".mui-table-view");
			var littleround = document.getElementsByClassName("little_round")
			if(mydata[i].isread == 0) {
				console.log(mydata[i].isread + ':' + i);
				littleround[i].style.display = 'block';
			}
	}
		if(mydata.length == 0) {
			var btnArray = ['确认'];
			mui.confirm('亲，您还没有消息呢', '', btnArray, function(e) {

			});
			$('<div id="nothing">'+
				'<img src="../../img/img_norecord.png"/>'+
				'<span>您还没有消息哦！</span>'+
			'</div>').appendTo(".jion_record_ing_inner");
		}
		var littleround = document.getElementsByClassName("little_round");
			var xfli = document.getElementsByClassName("mui-table-view-cell");
		//点击之后改变是否阅读状态
		for(var j = 0; j < mydata.length; j++) {
			xfli[j].index=j;
			xfli[j].addEventListener('tap', function() {
//				console.log(this.index);
				littleround[this.index].style.display = 'none';
				if(mydata[this.index].isread == 0) {
					doread(mydata[this.index].id);
				}
			})
		}
	},
	error: function() {
		mui.toast('加载失败，请重试');

	}
});*/

$(function(){
	/*获取是否有未读的系统消息*/
    function unread(){
        var phone=localStorage.getItem("user");

        var data={
            'phone':phone
        }
        util.ajax('unread',data,unreadHnander);
    }
    function unreadHnander(data){
    	console.log(data);
		if(data.gonbgao){
            $('#notice').css("display",'block');
		}else{
            $('#notice').css("display",'none');
		}
		if(data.huodogn){
            $('.notice').css("display",'block');
		}else{
            $('.activity').css("display",'none');
		}
    }
    unread();

    $('.mui-table-view li').click(function(){
		var inforId=$(this).find('.little_round').attr('id');
		localStorage.setItem('inforId',inforId);
		location.href='message_detail.html';
	});
});